#include "askmoney.h"
#include "ui_askmoney.h"
#include "dialog.h"
#include "string"
#include <QString>
#include <vector>
#include "program.h"
#include "bigsave.h"
#include <QMessageBox>
using std::string;
extern vector <Program*> prdata;

askmoney::askmoney(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::askmoney)
{
    ui->setupUi(this);
}

askmoney::~askmoney()
{
    delete ui;
}

void askmoney::on_pushButton_clicked()
{
    QString p = ui->lineEdit->text();
      QString j= ui->lineEdit_2->text();
      float t = j.toFloat();
      if(p!=""&&t!=0){
        for(unsigned int i=0;i<prdata.size();i++)
        {
            if(prdata[i]->ifhave(p))
            {
                prdata[i]->addmoney(t);
                bigsave();
                QMessageBox::information(this,"提示","申请资金成功，请等待批准");
                return;
            }
        }}
        QMessageBox::critical(this,"错误","错误");
}

void askmoney::on_pushButton_2_clicked()
{
    this->close();
    Dialog *p = new Dialog;
    p->show();
}
